import { http } from "@/utils/http";

export type UserListResult = {
  code: number;
  data: Array<any>;
};

export type Page = {
  pageSize: number;
  pageNum: number;
};

export const getUserList = (data?: object) => {
  return http.request<UserListResult>("get", "/admin/getAllUser", { data });
};

export const getUserPage = (data?: Page) => {
  return http.request<UserListResult>(
    "get",
    `/admin/getUserPage?pageNum=${data.pageNum}&pageSize=${data.pageSize}`
  );
};

export const addUser = (data?: object) => {
  return http.request("post", "/admin/addUser", { data });
};

export const updateUserById = (data?: object) => {
  return http.request("put", "/admin", { data });
};

export const updateUserStatusById = (uid: number, status: number) => {
  return http.request("put", `/admin/${uid}/${status}`);
};

export const deleteUserById = (data?: object) => {
  return http.request("delete", "/admin", { data });
};
